(function(a) {
    a.fn.hoverIntent = function(b, c) {
        var d = {
            sensitivity: 7,
            interval: 100,
            timeout: 0
        };
        d = a.extend(d, c ? {
            over: b,
            out: c
        } : b);
        var e, f, g, h, i = function(a) {
            e = a.pageX, f = a.pageY;
        }, j = function(b, c) {
            c.hoverIntent_t = clearTimeout(c.hoverIntent_t);
            if (Math.abs(g - e) + Math.abs(h - f) < d.sensitivity) {
                a(c).unbind("mousemove", i), c.hoverIntent_s = 1;
                return d.over.apply(c, [ b ]);
            }
            g = e, h = f, c.hoverIntent_t = setTimeout(function() {
                j(b, c);
            }, d.interval);
        }, k = function(a, b) {
            b.hoverIntent_t = clearTimeout(b.hoverIntent_t), b.hoverIntent_s = 0;
            return d.out.apply(b, [ a ]);
        }, l = function(a) {
            var b = (a.type == "mouseover" ? a.fromElement : a.toElement) || a.relatedTarget;
            while (b && b != this) try {
                b = b.parentNode;
            } catch (c) {
                b = this;
            }
            if (b == this) return !1;
            var e = jQuery.extend({}, a), f = this;
            f.hoverIntent_t && (f.hoverIntent_t = clearTimeout(f.hoverIntent_t)), a.type == "mouseover" ? (g = e.pageX, h = e.pageY, c(f).bind("mousemove", i), f.hoverIntent_s != 1 && (f.hoverIntent_t = setTimeout(function() {
                j(e, f);
            }, d.interval))) : (c(f).unbind("mousemove", i), f.hoverIntent_s == 1 && (f.hoverIntent_t = setTimeout(function() {
                k(e, f);
            }, d.timeout)));
        };
        return this.mouseover(l).mouseout(l);
    };
})(jQuery);